<script setup lang="ts">
import { ref } from 'vue'
import img_obj_3d_1_svg from '~/assets/svgs/obj_3d_1.svg'
import img_obj_3d_2_svg from '~/assets/svgs/obj_3d_2.svg'
import img_obj_3d_3_svg from '~/assets/svgs/obj_3d_3.svg'
import img_obj_3d_4_svg from '~/assets/svgs/obj_3d_4.svg'

const form = ref({
  username: '',
  password: '',
})
const formRef = ref()

function onLogin() {
  formRef.value.validate((valid: boolean) => {
    if (valid) {
      // Perform login logic here
      console.warn('Login successful:', form.value)
    }
    else {
      console.warn('Login failed')
      return false
    }
  })
}
</script>

<template>
  <div class="my-login-container">
    <img :src="img_obj_3d_1_svg" class="my-login-obj">
    <img :src="img_obj_3d_2_svg" class="my-login-obj">
    <img :src="img_obj_3d_3_svg" class="my-login-obj">
    <img :src="img_obj_3d_4_svg" class="my-login-obj">
    <div class="my-login-form">
      <div mb4>
        登录
      </div>
      <el-form ref="formRef" :model="form" label-width="80px">
        <el-form-item label="用户名" prop="username" :rules="[{ required: true, message: '请输入用户名', trigger: 'blur' }]">
          <el-input v-model="form.username" placeholder="请输入用户名" />
        </el-form-item>
        <el-form-item label="密码" prop="password" :rules="[{ required: true, message: '请输入密码', trigger: 'blur' }]">
          <el-input v-model="form.password" type="password" placeholder="请输入密码" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onLogin">
            登录
          </el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="my-login-footer">
      <p>© 2025 前端模板. All rights reserved.</p>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.my-login-container {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: linear-gradient(135deg, #ffffff, #007bff, #ffffff);
  background-size: 500% 500%;
  .my-login-obj {
    position: absolute;
    top: 26%;
    left: 12%;
    width: 32%;
    height: auto;
    &:nth-child(2) {
      width: 8%;
      height: auto;
      left: 13%;
      top: 27%;
      animation: my-login-obj-animation 5s ease-in-out infinite;
    }
    &:nth-child(3) {
      width: 8%;
      height: auto;
      left: 13%;
      top: 65%;
      animation: my-login-obj-animation 5s ease-in-out infinite;
    }
    &:nth-child(4) {
      width: 7%;
      height: auto;
      left: 36%;
      top: 30%;
      animation: my-login-obj-animation 5s ease-in-out infinite;
    }
  }
  @keyframes my-login-obj-animation {
    0% {
      transform: scale(1);
    }
    50% {
      transform: translate(0, -10%) scale(1.05);
    }
    100% {
      transform: scale(1);
    }
  }
  .my-login-form {
    position: absolute;
    top: 30%;
    right: 10%;
    width: 400px;
    height: fit-content;
    padding: 20px;
    background-color: #ffffff;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 1;
  }
  .my-login-footer {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #ffffff;
    font-size: 14px;
    text-align: center;
  }
}
</style>
